#ifndef RINGBUFFER__H__
#define RINGBUFFER__H__
#include <stdint.h>
typedef struct _ringbuffer {
    uint8_t *buffer;
    uint32_t buffer_size;
    uint32_t read_mirror : 1;
    uint32_t read_index : 31;
    uint32_t write_mirror : 1;
    uint32_t write_index : 31;
} ringbuffer_t;

int ringbuffer_init(ringbuffer_t *rb, uint8_t *buffer, uint32_t size);
int ringbuffer_reset(ringbuffer_t *rb);
int ringbuffer_putchar(ringbuffer_t *rb, uint8_t ch);
int ringbuffer_getchar(ringbuffer_t *rb, uint8_t *ch);

#endif  // RINGBUFFER__H__
